package com.jeez.gateway.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

//@Component
public class PostFilter extends ZuulFilter {

	private static final Logger LOG = LoggerFactory.getLogger(PostFilter.class);  
	
	@Override
	public Object run() {
		RequestContext ctx = RequestContext.getCurrentContext();  
        
		LOG.info("进入post过滤器");  
        System.out.println(ctx.getResponseBody());  
  
        //int i = 1 / 0;
        
        return ctx;  
	}

	@Override
	public boolean shouldFilter() {
		//是否执行该过滤器，true代表需要过滤 
		return true;
	}

	@Override
	public int filterOrder() {
		//优先级. 数字越大，优先级越低  
		return 0;
	}

	/**
	 * post 后置过滤器
	 * pre 前置过滤器
	 * error 异常过滤器
	 */
	@Override
	public String filterType() {
		//前置过滤器
		return "post";
	}

}
